import unittest
import l_function


class MyTestCase(unittest.TestCase):
    def test_not_copy(self):
        r = [7, 6, 5, 4, 3, 2, 1]
        r2 = l_function.L(r, copy=False)
        self.assertSequenceEqual([1, 2, 3, 4, 5, 6, 7], r)
        self.assertIs(r, r2)

        r = list("abcd")
        r2 = l_function.L(r, copy=False)
        self.assertSequenceEqual(list("dcba"), r)
        self.assertIs(r, r2)

        r = []
        r2 = l_function.L(r, copy=False)
        self.assertSequenceEqual([], r)
        self.assertIs(r, r2)

        r = ["m"]
        r2 = l_function.L(r, copy=False)
        self.assertSequenceEqual(["m"], r2)
        self.assertIs(r, r2)

    def test_copy(self):
        r = [7, 6, 5, 4, 3, 2, 1]
        r2 = l_function.L(r)
        self.assertSequenceEqual([1, 2, 3, 4, 5, 6, 7], r2)
        self.assertSequenceEqual([7, 6, 5, 4, 3, 2, 1], r)

        r = list("abcd")
        r2 = l_function.L(r)
        self.assertSequenceEqual(list("dcba"), r2)
        self.assertSequenceEqual(list("abcd"), r)

        r = []
        r2 = l_function.L(r)
        self.assertSequenceEqual([], r)
        self.assertSequenceEqual([], r)

        r = ["m"]
        r2 = l_function.L(r)
        self.assertSequenceEqual(["m"], r2)
        self.assertSequenceEqual(["m"], r)

if __name__ == '__main__':
    unittest.main()
